Cleaned up for the sake of modularity.