Simplify and match up nearer the PHP library