Changed private functions to prototype functions.

Fixed a couple small bugs.  Undo is still about half implemented.