Reorganised program and made preparations to use as library
cleanup, passes weak splint check
More splint cleanup, increased splint level slightly