Major code changes + Tests