Code cleanup and bug fixes which closes #1