Given the number of arguments, we should really start adding some OOP/classes here. For now, it's OK, I guess.