Working alpha. Added cleaning functions, needs hooking.