Code cleanup, added example application