fixxed a few bugs with rotate and layout