Code Improvements

Added some code improvements based on some suggestions.