Made memory management changes based on the pull request https://github.com/sjdirect/abot/pull/39