tidy up (functions moved to BBmisc), use ".self" instead of "self" to
avoid collisions