Refactored model rendering code

Finallly did it, I've been trying to do so for a while and was getting seg. fault erros. Remember the operators precedence (* and [])

Reorganized some global variables to common.h