lr2 added plus some cython optimization