Various code improvements and annotations