Fixed map planning bugs.
Merge.