Major fixes, and cleanup. Finished library code and most of the GUI.