Improved code readability and refactored

Adjusted some minor mistakes and improved the code readability.