Various cleanup & bug fixes

Moved source to src directory.  Fixed various bugs (although didn't fix
any of the format errors).