added assertions, fixed constructors, added documentation