Answer for question at StackOverlfow.
See http://stackoverflow.com/q/27519128/940720