Some code cleanup, small improvements