Refactored analysis library for consistency and clarity