Code works fine, but has not finished yet. Also did some cleaning up.