Fixed bugs, and linking issue