Cleaned up code and added options for CascadeType