Rewritten in OOP style, reduced field size