fixed some small bugs found when running refactored code in GAE