Fix several bugs, update gitignore