Fixed bug in linearization