Cleaned and reformatted some core code.