Better exception usage and code cleanup.