Refactor types

This now compiles and passes all tests. It replaces the VarWithValue and ValueBound traits with explicit managing of the Value member.