improved non-linear algorithms and code organization