Fixed a bug and resolved build errors