Several improvements

Please pull these commits. Let me know if you have any questions!