Cleaned up codes and fixes.