Cleaned up the base code