Use attached callback instead of created callback

Also a bunch of minor cleanups.