Complete re-write!

Started completely re-writing this for 1.6.2.