Small bug fixes and added functions