refactor and decouple processing

fix updating PHP method (offset was off)

fixes #5
fixes #6