Paypal fork

Mostly minor changes/improvements as I was going through some code.
Please define a more specific type for parameter `$var`; consider using a union like `null|Object`, or `string|array`.