implement all toplevel definitions