Pull Request --- Code Improvements

Submitting pull request for refactoring and styling of code:

* Remove unecessary objects (e.g. Array) and refactor methods.
* Rewrite code to improve maintainability and readability.

Please see pull request for code change details.

Recommend to test changes before accepting pull request.

Thanks! CJL