Fixed some bugs and completely removed glm