refactor and cleanup; add formatting config