Fixed Bugs, improved speed

Fixed some minor issues and improved b
Merge pull request #2 from samuelbeek/master

Fixed Bugs, improved speed