fixed leak by: https://gist.github.com/steinn/55537c95023c9f54aa83