Some code cleaned up