Add verbose debugging flag
Bug fixing and cleanup