Added test for engine, corrected several bugs. Dropped sqrt weights.