Minor changes.
Bugs fixed, refactoring code.