Value type

Add full support for value-types.

Scrutinizer will probably complain a bit about methods complexity, I'll (hopefully) fix that tomorrow.
You should maybe add an extra attribute to d to make sure it is kept.