Improve sample project and fix bugs with autorotation