Code cleanup thanks to Alex