fixed broken function references, math error, text fixes, code style