refactored serialisation engine and added run time type information support