bugfixes and style changes. also, probably, new bugs