many changes, thanks to aibo for auditing and for the fixes