some cleanup and small fixes