Rewritten a lot of stuff