Remove redundant code and tidy