fixed linking bugs, refactored backend code