Reorganized library inplementation into one source file.