bug fixes, reformatting