some fiddling and bug fixing