Fixes #5, some more refactoring may still be needed
Fixes #5, some more refactoring may still be needed