Fixed and simplified model definitions.
Memory leak fixes.