Implemented everything except uniforms

Untested. Very unlikely to work first time.