major fixes, careful it is a little "loose"