simple algebra!

and bug fixes