Fix and optimize a few things
Merge pull request #3 from Arcterus/master

Fix and optimize a few things