Some fixes and improvements, added example