Linearize class

PR with my own master, for code review purposes. Please take a look.