Fixed a stupid copy-by-reference bug and resolved rotation logic.