convert tabs to spaces; cleanup code a bit