Fix several issues to make it work