This is a little too busy/complicated for my liking but it's a place to start and hopefully we'll be able to cut this down a little after we see how the planning engine implementation turns out. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>