Corrected multiple errors and cleaned up code.