Fixed minor bugs and testing