Cleaned up the code, minor tweaks.