code cleaned up for public release