code improvements & cleanup