Remove some unused code and simplified a few things