Context binding instead of variable closure

Refactored to more modern and elegant way to use necessary context inside callback functions.