reimplemented constraints; lots of inline doc. and cleanup