Fixed minor bugs and cleaned code.
Merge remote-tracking branch 'origin/master'