cleaned up the code; fixes #25