Code reformatting and cleanup