Some beautychanges to the code;