Fixed amount bug and cleaned up some code.