Cleaing up some minor errors and bugs