Halfcanonical rings on algebraic curves and applications to surfaces of general type