Random code improvements