Several code enhancements