improved map planning.
Code cleanup.