refactor serialization

Drop automatic property serialization in favour of hand-written code.
The disadvantage is more code to maintain. However, the code is very
simple and allows to control more fine-grained what is serialized and
how the serialization is done.
Also, serialization to file and tikz export now shares the code, which
is much better.
code cleanup