Second commit - bug fixes