Refactor types

WARNING: DOESN'T COMPILE, DON'T MERGE

This tries to replace the var thing. I have no idea why it doesn't compile. Please check it out.