Implemented changes suggested by tialpoy on Reddit.