Fixed a large bug in linearization code. Should work now.