FIxed minor bugs overall the code.