Code refactor (still messy, but better than it was)