Fixed errors found during testing