Cleaned up some parts of the code