fixed some bugs, including (but not limited to) #112.
Merge pull request #114 from eggrobin/bugfixing

fixed some bugs, including (but not limited to) #112.