clean up. reducing compiler warnings. swapping let for where clauses when sensible