adding API 2.1 support and cleaning up some indenting