Add refs and clean up a bit