Further cleaned up code