v5.1: theoretical lower mem usage, and fixed some ugly code