Added else statements.
Fixed a few minor bugs.
Refactoring.