Improvements and fixes

Added some missing functionality that I needed for another project.