Added important hooks and cleaned things up.

Actually getting close to being functional!