Some minor improvements and cleanup