Minor code refactoring, Fixes #1