ready for browser use, cleanup code