Master code cleaned up