code cleanup and minor ui improvments