fixed code and link errors