Various code enhancements