fixed bugs with rotation and wrapping issues