Code cleanup & smaller fixes