random bug fixes and better random