Making this more generic. I hope I didn't break anything...