code cleanup/fixes