Fixed some bugs so it should work correctly now when you test
Merge pull request #1 from L1ghtn1ng/bugfix

fixed bugs
minor changes
fixed newline issues
prettied up