Improve userdata handling