Fixed IO and drawing functions