Changed use of SMatrix to pointers and on the stack. Also adding variable handling functions for creating and freeing matrices.

Signed-off-by: PandaDragonThing <jacob@linuxrocket.net>