Removed duplicate code and a few other stuff

whoops I forgot to commit this so I'm doing it late.