Fix several issues