Fixed issues chleggett found by auditing