refactored the code a bit more and cleaned up things
Merge remote-tracking branch 'origin/master'