Improved annotations and code cleanup