Cleaned up code, in case someone is looking :-)