Fixed up code a bit, added example use