Nicer names, moved some functions, based on Reinout's review