Fixed many bugs, updated interface and added new test scripts