Bug fixes, removed unnecessary functions.

Changed all if-else to switch statements.