Error optimization

debug everything, implement LP optimization, improve error metrics