implemented various controls + code cleanup