reformatting and remove obsolete sql stuff