fixing of issues pointed out by krlmlr and general tidy up