Fixed invalid function references, bad variable reference
Removed doc system
Fixed definition order