a little cleanup and refactoring, closes #64
little bugfix