Reorganized library inplementation into single source file.