Reworking some code to call fewer AJAX requests (can be improved further, but right now it's too early of an optimization)