Code cleanup, inspection and reformatting