Added rotation using matrices and other fixes