bug fixes, adds more functions