Rewrite to use base stuff

Signed-off-by: tachyony <tachyony@live.co.uk>