fixing link errors, tidying up