Seems to work now, still need to check against php output.
Merge remote-tracking branch 'origin/master'