Fixed all bugs; improved accuracy