Fixed potential crash when setting custom elements (thanks Marco Nilsson!); various cosmetic and integer sign/size fixes
Cosmetic: fixed various typos
Tiny typo in comment