Prettified. Added namespace, moved to apropriate places, etc