Reformatted code, added sample demo