fixes for memory leaks, autorotation