Fixed some bugs and made code consistent with documentation
Fixed next / previous actions