Cleaned up code to match prar branch better