refactoring due to hhvm memory leak #45