Debug: Throw an exception if the map edit API is used before MPE_Begin()

Plus some minor cleanup.